<html>
<head>
    <meta charset="UTF-8">
    <title>浏览计数器</title>
</head>
<body background="img/11-1.jpg">
<?php
//数字输出网页计数器
$max_len = 9;
$CounterFile = "counter.dat";
if(!file_exists($CounterFile)){        //如果计数器文件不存在
    $counter = 0;
    $cf = fopen($CounterFile,"w");  //打开文件
    fputs($cf,'0');                    //初始化计数器
    fclose($cf);                   //关闭文件
}
else{                                       //取回当前计数器的值
    $cf = fopen($CounterFile,"r");
    $counter = trim(fgets($cf,$max_len));
    fclose($cf);
}
$counter++;                                    //计数器加一
$cf = fopen($CounterFile,"w");              //写入新的数据
fputs($cf,$counter);
fclose($cf);
?>
<div id="dd" align="center">
    <span>欢迎您!</span>
        <span>您是本站的第
            <?php
            echo $counter;                            //输出计数器
            ?>
            位访客！</span>
</div>
<p align="center">信息B1833班 33号苏子翀出品 制作完成于2019年12月13日</p>

</body>
</html>
